package com.piesat.quake.business.device.mqtt;

import com.piesat.quake.business.device.mqtt.reader.CharReader;
import com.piesat.quake.business.device.mqtt.reader.IpReader;
import com.piesat.quake.business.device.mqtt.reader.NumberReader;
import com.piesat.quake.business.device.mqtt.reader.Reader;
import com.piesat.quake.business.device.mqtt.writer.CharWriter;
import com.piesat.quake.business.device.mqtt.writer.IpWriter;
import com.piesat.quake.business.device.mqtt.writer.NumberWriter;
import com.piesat.quake.business.device.mqtt.writer.Writer;

/**
 * 数据类型
 *
 * @author Gersy
 * @date 2023/2/6
 * @since 1.0
 */
public enum DataType {
    CHAR(new CharReader(),new CharWriter()),
    NUMBER(new NumberReader(),new NumberWriter()),
    IP(new IpReader(),new IpWriter());
    private final Reader reader;
    private final Writer writer;

    DataType(Reader reader, Writer writer) {
        this.reader = reader;
        this.writer = writer;
    }

    public Reader getReader() {
        return reader;
    }

    public Writer getWriter() {
        return writer;
    }

    public static Reader getReader(int index){
        return DataType.values()[index].reader;
    }

    public static Writer getWriter(int index){
        return DataType.values()[index].writer;
    }
}
